1 Libraries

library(dplyr)

library(plotly)

library(countrycode)

library(fontawesome)

2 Data

country <- c("Algeria",  "Argentina",  "Bangladesh",  "Barbados",  "Belarus",  "Belize",  "Benin",  "Bosnia and Herzegovina",  "Cameroon",  "Central African Republic",  "Chad",  "Democratic Republic of the Congo",  "Republic of the Congo",  "Costa Rica",  "Cote d'Ivoire",  "Dominican Republic",  "El Salvador",  "Eswatini",  "Ghana",  "Guinea",  "Guinea Bissau",  "Guyana",  "Iraq",  "Jamaica",  "Kazakhstan",  "Kenya",  "Kosovo",  "Kyrgyzstan",  "Laos", "Macedonia",  "Madagascar",  "Malawi",  "Mali",  "Mauritania",  "Mexico",  "Moldova",  "Mongolia",  "Montenegro",  "Nepal",  "Nigeria",  "Pakistan",  "Panama",  "Paraguay",  "Sao Tome and Principe",  "Senegal",  "Serbia",  "Sierra Leone",  "Somalia",  "St. Lucia",  "State of Palestine",  "Suriname",  "Thailand",  "The Gambia",  "Togo",  "Trinidad and Tobago",  "Tunisia",  "Turkmenistan",  "Ukraine",  "Uruguay",  "Vietnam",  "Zimbabwe")

MICScountries <- data.frame(country)

MICScountries$country_iso <- countrycode(MICScountries$country, 
                                 'country.name', 
                                 'iso3c')

3 Configuration

# geographic options

g <- list(showframe = TRUE, 
          showcoastlines = TRUE, 
          showcountries = TRUE,
          showland = TRUE,
          countrycolor = toRGB("grey"),
          showocean = TRUE,
          # projection = list(type = 'robinson'),
          projection = list(type = 'orthographic',
                            rotation = list(lon = 0,
                                            lat = 0,
                                            roll = 0)),
          showland = TRUE,
          landcolor = toRGB("grey"))

g2 <- list(showland = TRUE,  
           landcolor = toRGB("grey"),
           showcountries = TRUE,
           showocean = FALSE, 
           projection = list(type = 'orthographic',
                             rotation = list(lon = 0,
                                             lat = 0,
                                             roll = 0)),
           lataxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")),
           lonaxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")))

g3 <- list(showland = TRUE,  
           landcolor = toRGB("grey"),
           showcountries = TRUE,
           showocean = FALSE, 
           projection = list(type = 'robinson'),
           lataxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")),
           lonaxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")))

# text options

t <- list(
  family = "sans serif",
  size = 8,
  color = toRGB("black"))

# line options

l <- list(color = toRGB("grey"), width = 0.5)

4 Globes

NB that the globes allow you to take a snapshot of a particular view with the icon.

4.1 One

MICScountries %>% 
  plot_geo() %>% 
  add_trace(text = ~country, 
            # z = 1,
            hoverinfo = 'text',
            locations = ~country_iso, 
            marker = list(size = 10, color = "red")) %>%
  layout(geo = g)

4.2 Two

MICScountries %>% 
  plot_geo() %>%   
  add_trace(locations = ~country_iso,
            color = 1,
            z = 1, 
            text = ~country, 
            hoverinfo = 'text',
            colors = colorRamp(c("gold", "gold")),
            marker = list(line = l),
            showscale = FALSE) %>%
  layout(geo = g2)

4.3 Three (Not really a globe, but shows the whole earth at one time)

MICScountries %>% 
  plot_geo() %>%   
  add_trace(locations = ~country_iso,
            color = 1,
            z = 1, 
            text = ~country, 
            hoverinfo = 'text',
            colors = colorRamp(c("gold", "gold")),
            marker = list(line = l),
            showscale = FALSE) %>%
  layout(geo = g3)